package cn.zebra.dev.product.module.sku.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 商品sku
 *
 * @author runnable@sina.cn
 */
@TableName("product_sku")
@Getter
@Setter
public class ProductSkuEntity {
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "商品id", hidden = true)
    private Long productId;

    @ApiModelProperty(value = "Sku编码")
    private String productSkuSn;

    @ApiModelProperty("商品sku规格图片")
    private String productSkuImage;

    @ApiModelProperty("sku名称")
    private String productSkuName;

    @ApiModelProperty("成本价")
    private BigDecimal costPrice;

    @ApiModelProperty("销售价")
    private BigDecimal marketPrice;

    @ApiModelProperty("单价(销售价)")
    @NotNull(message = "销售价不能为空!")
    @DecimalMin(value = "0.0001", message = "销售价不能小于0.0001!")
    private BigDecimal unitPrice;

    @ApiModelProperty("重量kg")
    private BigDecimal weight;

    @ApiModelProperty("体积m³")
    private BigDecimal volume;

    @ApiModelProperty("总数量(库存)")
    private Long totalNum;

    @ApiModelProperty("是否显示")
    private Boolean showFlag;

    @ApiModelProperty("是否删除")
    private Boolean deleteFlag;

    @ApiModelProperty("创建人")
    private Long createId;

    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty("更新人")
    private Long updateId;

    @ApiModelProperty("更新时间")
    private LocalDateTime updateTime;

    @ApiModelProperty("sku规格内容")
    @TableField(exist = false)
    private List<ProductSkuAttributeEntity> attrEntities;

    public void setProductSkuSn(Long timeMillis) {
        this.productSkuSn = timeMillis.toString();
    }

    public void setProductSkuSn(String productSkuSn) {
        this.productSkuSn = productSkuSn;
    }
}
